<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFreightTemplateTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('freight_template', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->comment('运费模板名称');
            $table->unsignedTinyInteger('is_default')->default(0)->comment('是否是默认模板 0:不是  1:是');
            $table->unsignedInteger('service_id')->index()->comment('站点id');
            $table->string('province_ids')->comment('省ID组');
            $table->string('city_ids')->comment('省id组');
            $table->string('district_ids')->comment('县区id组');
            $table->unsignedTinyInteger('is_weight')->default(0)->comment('是否启用重量运费  0:未启用  1:已启用');
            $table->decimal('first_weight', 10, 2)->default(0.00)->comment('首重');
            $table->decimal('first_weight_price', 10, 2)->default(0.00)->comment('首重运费');
            $table->decimal('continued_weight', 10, 2)->default(0.00)->comment('续重');
            $table->decimal('continued_weight_price', 10, 2)->default(0.00)->comment('续重运费');
            $table->unsignedTinyInteger('is_volume')->default(0)->comment('是否启用体积计算运费  0:未启用  1:已启用');
            $table->decimal('first_volume', 10, 2)->default(0.00)->comment('首 体积量');
            $table->decimal('first_volume_price', 10, 2)->default(0.00)->comment('首体积量运费');
            $table->decimal('continued_volume', 10, 2)->default(0.00)->comment('续 体积量');
            $table->decimal('continued_volume_price', 10, 2)->default(0.00)->comment('续体积量运费');
            $table->unsignedTinyInteger('is_piece')->default(0)->comment('是否启用计件方式计算运费  0:未启用  1:已启用');
            $table->decimal('first_piece', 10, 2)->default(0.00)->comment('首件');
            $table->decimal('first_piece_price', 10, 2)->default(0.00)->comment('首件运费');
            $table->decimal('continued_piece', 10, 2)->default(0.00)->comment('续件');
            $table->decimal('continued_piece_price', 10, 2)->default(0.00)->comment('续件运费');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('freight_template');
    }
}
